package com.sg.garaweb_info;

import javax.servlet.annotation.WebServlet;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("garaweb_info")
public class GarawebInfoUI extends UI {
	
	final VerticalLayout windowLayout = new VerticalLayout();
	final VerticalLayout appLayout = new VerticalLayout();
	final HorizontalLayout menuLayout = new HorizontalLayout();
	
	final HorizontalLayout searchLayout = new HorizontalLayout();
	
	private TextField searchField = new TextField();
	
	
	@WebServlet(value = "/*", asyncSupported = true)
	@VaadinServletConfiguration(productionMode = false, ui = GarawebInfoUI.class)
	public static class Servlet extends VaadinServlet {
	}

	@Override
	protected void init(VaadinRequest request) {
		windowLayout.setSizeFull();
		
		appLayout.setWidth("1000px");
		appLayout.setHeight("100%");
		appLayout.setMargin(true);
		
		windowLayout.addComponent(appLayout);
		windowLayout.setComponentAlignment(appLayout, Alignment.TOP_CENTER);
		
		initMenu();
		appLayout.addComponent(menuLayout);
		appLayout.setComponentAlignment(menuLayout, Alignment.TOP_CENTER);
		
		initSearchLayout();
		appLayout.addComponent(searchLayout);
		appLayout.setComponentAlignment(searchLayout, Alignment.TOP_CENTER);
		
		setContent(windowLayout);
	}
		
	private void initMenu(){
		//menuLayout.setWidth("100%");
		menuLayout.setHeight("100px");
		//menuLayout.setSpacing(false);
		menuLayout.addComponent(new Button("Home"));
		menuLayout.addComponent(new Button("About"));		
	}
	
	private void initSearchLayout(){
		searchLayout.setHeight("100px");
		searchField.setWidth("150px");
		searchField.setCaption("Introduceti filtru: ");
		
		searchLayout.addComponent(searchField);
		searchLayout.addComponent(new Button("Cauta"));
		
	}

	
}	
//	final GridLayout gridLayout = new GridLayout(3,1);
//	final VerticalLayout mainLayout = new VerticalLayout();
//	
//	
//	private HorizontalLayout topLayout = new HorizontalLayout();
//	private HorizontalLayout contentLayout = new HorizontalLayout();
//	private HorizontalLayout bottomLayout = new HorizontalLayout();
//
//	@WebServlet(value = "/*", asyncSupported = true)
//	@VaadinServletConfiguration(productionMode = false, ui = GarawebInfoUI.class)
//	public static class Servlet extends VaadinServlet {
//	}
//
//	@Override
//	protected void init(VaadinRequest request) {
//	
//		
//		initTopLayout();
//		initMiddleLayout();
//		initBottomLayout();
//		
//		gridLayout.setMargin(true);
//		gridLayout.setWidth("100%"); 
//		gridLayout.setHeight("100%");
//		
//		
//		 
//		mainLayout.setSizeFull();
//		//mainLayout.setWidth( "1000px"); 
//		//mainLayout.setHeight("800px");
//		
//		
//		mainLayout.addComponent(topLayout);
//		mainLayout.addComponent(contentLayout);
//		mainLayout.addComponent(bottomLayout);
//		
//		
//		mainLayout.setExpandRatio(topLayout, 		1.0f);
//		mainLayout.setExpandRatio(contentLayout, 	10.0f);
//		mainLayout.setExpandRatio(bottomLayout, 	2.0f);
//		
//		gridLayout.addComponent(new VerticalLayout(),0,0);
//		gridLayout.addComponent(mainLayout, 1, 0);
//		gridLayout.addComponent(new VerticalLayout(),2,0);
//		
//		setContent(gridLayout);
//		
//	}
//	
//	 private void initTopLayout() {
//		 Panel pnl = new Panel("Top Panel");
//		 topLayout.addComponent(pnl);
//		 topLayout.setWidth("100%");
//		 topLayout.setHeight("200px");
//	 }
//	 
//	 private void initMiddleLayout() {
//		 
//		 contentLayout.setSizeFull();
//		 contentLayout.addComponent(new Panel("Middle Panel")); 
//	 }
//	 
//	 private void initBottomLayout() {
//		 bottomLayout.setWidth("100%");
//		 bottomLayout.setHeight("100px");
//		 bottomLayout.addComponent(new Panel("Bottom Panel"));
//	 }	 
//	 

